﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Pages_routeMap : System.Web.UI.Page
{
    algemeen alg = new algemeen();
    protected void Page_Load(object sender, EventArgs e)
    {


        string sql_query = "Select van.straatnaam , van.huisnummer , van.plaats , naar.straatnaam , naar.huisnummer , naar.plaats FROM rij_route , locatie as van , locatie as naar WHERE transport_id = " + Request.QueryString["query"] + " AND rij_route.locatie_id_van = van.locatie_id AND rij_route.locatie_id_naar = naar.locatie_id ";
        SqlConnection connection = new SqlConnection(alg.sql_string);
                                                            
   
        
        using (SqlCommand command = new SqlCommand(sql_query, connection))
        {
            connection.Open();
            string route = "";
            SqlDataReader objDataReader = command.ExecuteReader();
            if(objDataReader.Read())
            route = "from: " + objDataReader.GetString(0).Trim() + " " + objDataReader.GetString(1).Trim() + " , " + objDataReader.GetString(2).Trim() + ", Nederland to: " + objDataReader.GetString(3).Trim() + " " + objDataReader.GetString(4).Trim() + " , " + objDataReader.GetString(5).Trim() + " , Nederland";

            while (objDataReader.Read())
            {
                route += " to:" + objDataReader.GetString(3).Trim() + " " + objDataReader.GetString(4).Trim() + " , " + objDataReader.GetString(5).Trim() + ", Nederland";
            }
            this.Label1.Text = "<script language=\"javascript\">waardeMap = \"" + route + "\"; </script>" + route;
            connection.Close();
        }
    }
}
